function [dates,data,headers] = gFileOpen(fileName,nanText)
% GFILEOPEN Parses the common GLEON format for high resolution data
%
% 

allowedNanText = {'na','NA','N/A','n/a'};

if(nargin > 1)
    if(~any(strcmp(allowedNanText,nanText)))
        error(['nan text supplied no allowed. Remember, nan, ' ...
            'NaN, and NAN are already handled. Only define nanText ' ...
            'when using something other than those.']);
    end
else
    nanText = {};
end


    fid = fopen(fileName);

    headers = fgetl(fid);
    headers = regexp(headers,'\t','split');
    format = '%s';
    for i=2:length(headers);
        format = strcat(format,'%f');
    end
    headers = headers(2:end); % drop the first, datetime, column
    
    d = textscan(fid,format,'delimiter','\t','TreatAsEmpty',nanText);
    fclose(fid);
    
    
    data = horzcat(d{2:end});
    dates = datenum(d{1},'yyyy-mm-dd HH:MM');

end